﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace MyCraft
{
    class Rectangle9
    {
        #region Attributs
        public Rectangle Rectangle;
        public Vector2 CenterV;
        public Rectangle Corner_tl, Corner_tr, Corner_bl, Corner_br;
        public Rectangle Edge_top, Edge_bottom, Edge_left, Edge_right;
        public Rectangle CenterR;
        #endregion

        #region Constructeur
        public Rectangle9(Rectangle rectangle, Vector2 offset)
        {
            this.Rectangle = rectangle;
            CenterR = new Rectangle(rectangle.X + (int)offset.X, rectangle.Y + (int)offset.Y, rectangle.Width - (int)(2 * offset.X), rectangle.Height - (int)(2 * offset.Y));
            CenterV = new Vector2(CenterR.X, CenterR.Y);

            Vector2 tl = CenterV;
            Vector2 tr = new Vector2(CenterR.Right - rectangle.Right, CenterR.Top - rectangle.Top);
            Vector2 bl = new Vector2(CenterR.Left, CenterR.Bottom);
            Vector2 br = new Vector2(CenterR.Right, CenterR.Bottom);

            Corner_tl = new Rectangle(Rectangle.X, Rectangle.Y, (int)offset.X, (int)offset.Y);
            Edge_top=new Rectangle(Corner_tl.Right, Corner_tl.Top, CenterR.Width, Corner_tl.Height);
            Corner_tr = new Rectangle(Edge_top.Right, Edge_top.Top, (int)offset.X, (int)offset.Y);

            Edge_left = new Rectangle(Rectangle.X, Corner_tl.Bottom, (int)offset.X, CenterR.Height);
            Edge_right = new Rectangle(CenterR.Right, CenterR.Top, (int)offset.X, CenterR.Height);

            Corner_bl = new Rectangle(Rectangle.X, Edge_left.Bottom, (int)offset.X, (int)offset.Y);
            Edge_bottom = new Rectangle(Corner_bl.Right, Corner_bl.Top, CenterR.Width, Corner_tl.Height);
            Corner_br = new Rectangle(Edge_bottom.Right, Edge_bottom.Top, (int)offset.X, (int)offset.Y);
        }
        #endregion

        #region Methodes
        public bool intersect(int x, int y)
        {
            return (x > Rectangle.Left && x < Rectangle.Right && y > Rectangle.Top && y < Rectangle.Bottom);
        }
        #endregion
    }
}
